package com.example.demo.pay;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class Result {
	private Integer code;  // 给前端返回的状态码
	private String msg;  // 提示信息
	private Object data;  // 返回数据

	private enum Info {
		success, fail
	}

	// 通过的成功
	public static Result buildSuccess() {
		return buildSuccess(Info.success.toString());
	}

	public static Result buildSuccess(Object data) {
		return buildSuccess(Info.success.toString(), 1, data);
	}

	public static Result buildSuccess(String msg) {
		return buildSuccess(msg, 1);
	}

	public static Result buildSuccess(String msg, Integer code) {
		return buildSuccess(msg, code, null);
	}

	public static Result buildSuccess(String msg, Integer code, Object data) {
		return Result.builder().code(code).msg(msg).data(data).build();
	}
}
